package com.example.rabbitdemo.exchanger.topic;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

// 2. 生产者：发送不同路由键的消息
@Service
public class TopicProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    
    public void sendUsaNews() {
        rabbitTemplate.convertAndSend("exchange.topic", "usa.news", "美国新闻消息");
    }
    
    public void sendEuropeNews() {
        rabbitTemplate.convertAndSend("exchange.topic", "europe.news", "欧洲新闻消息");
    }
    
    public void sendUsaWeather() {
        rabbitTemplate.convertAndSend("exchange.topic", "usa.weather", "美国天气消息");
    }
}